<template>
	<view>
		<page-head :title="'个人信息'" :headtype="2"></page-head>
		<view class="mylist marginAuto">
			<view class="item flex" style="padding: 0;">
				<view class="itemmsg flex">
					<view class="itemmsgtitle" style="line-height: 80rpx;">头像</view>
				</view>
				<view class="itemicon" @click="uploadhead()">
					<image v-if="!usermsg.avatar" :src="apifun.serveimg + 'mrhead.png'" mode=""></image>
					<image v-if="usermsg.avatar" :src="apifun.URLimg+usermsg.avatar" mode=""></image>
				</view>
			</view>
			<view class="item flex">
				<view class="itemmsg flex">
					<view class="itemmsgtitle">企业名称</view>
				</view>
				<view class="itemicon">{{ usermsg.company_name }}</view>
			</view>
			<view class="item flex">
				<view class="itemmsg flex">
					<view class="itemmsgtitle">企业类型</view>
				</view>
				<view class="itemicon">
					<text v-if="usermsg.company_type.includes('1')" style="margin-right:20rpx;">工业</text>
					<text v-if="usermsg.company_type.includes('2')">农业</text>
				</view>
			</view>
			<view class="item flex">
				<view class="itemmsg flex">
					<view class="itemmsgtitle">姓名</view>
				</view>
				<view class="itemicon">
					<input class="input" style="text-align:right;" disabled="" type="text" v-model="usermsg.username" placeholder="请输入姓名"/>
				</view>
			</view>
			<view class="item flex">
				<view class="itemmsg flex">
					<view class="itemmsgtitle">手机号</view>
				</view>
				<view class="itemicon flex">
					<text>{{ usermsg.mobile }}</text>
					<!-- <uv-icon name="arrow-right" color="#999999" size="20"></uv-icon> -->
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				apifun:this.apifun,
				usermsg:{}
			};
		},
		onLoad() {
			this.usermsgfun()
		},
		methods: {
			usermsgfun(){
				this.apifun.unirequest('/user/user/getUserInfo','post',{},(res)=>{
					// console.log(res)
					if(res.code === 200){
						let datas = res.data;
						this.usermsg = datas;
						uni.setStorageSync('usermsg',datas);
					}else{
						this.apifun.toast(res.msg)
					}
				})
			},
			uploadhead(){
				this.apifun.uploadFileimg((res)=>{
					if(res.code == 200){
						this.usermsg.avatar = res.data.src
						this.setavaterfun()
					}
				},this)
			},
			setavaterfun(){
				this.apifun.unirequest('/common/user/setUserAvatar','post',{
					avatar:this.usermsg.avatar
				},(res)=>{
					if(res.code === 200){
						let datas = res.data;
					}else{
						this.apifun.toast(res.msg)
					}
				})
			}
		},
	};
</script>

<style scoped lang="scss">
	page{
		background-color: #FBFBFB;
	}
	.mylist{
		width: 630rpx;
		padding:30rpx;
		background-color: #fff;
		border-radius: 20rpx;
		margin-top: 20rpx;
		.item{
			padding: 34rpx 0;
			justify-content: space-between;
			border-bottom: 1px solid #F4F4F4;
			.itemmsg{
				.itemmsgimg{
					width: 40rpx;
					height: 40rpx;
					image{
						width: 40rpx;
						height: 40rpx;
					}
				}
				.itemmsgtitle{
					line-height: 40rpx;
					font-size: 30rpx;
					color: #333333;
					margin-left: 10rpx;
				}
			}
			.itemicon{
				font-size:30rpx;
				color: #333333;
				image{
					width: 80rpx;
					height: 80rpx;
					border-radius: 100rpx;
				}
				.input{
					list-style:50rpx;
					width:200rpx;
					text-align: right;
					font-size:30rpx;
					color: #333333;
				}
			}
		}
	}
</style>